class Solution {
public:
    bool isPalindrome(ListNode* head) {
        vector<int> Vals;
        while (head != nullptr)
        {
            Vals.push_back(head->val);
            head = head->next;
        }
        for (int i = 0, j = Vals.size() - 1; i < j; i++, j--)
        {
            if (Vals[i] != Vals[j])
                return false;
        }
        return true;
    }
};